# schemas/meeting.py
from typing import Union
from datetime import datetime
from pydantic import Field, BaseModel
from fastapi import Query

from admin.schemas.base import CamelModel


class MeetingsListIn(CamelModel):
    title: Union[str, None] = Field(default=None)
    owner_id: Union[int, None] = Field(default=None)

    class Config:
        from_attributes = True
        field_operator_mapping = {
            "title": "LIKE",
            "owner_id": "=",
        }


class MeetingsDetailIn(CamelModel):
    id: int = Query(..., gt=0)


class MeetingsAddIn(CamelModel):
    title: str = Field(...)
    description: Union[str, None] = Field(default=None)
    owner_id: Union[int, None] = Field(default=None)
    start_time: Union[datetime, None] = None
    end_time: Union[datetime, None] = None


class MeetingsEditIn(MeetingsAddIn):
    id: int = Field(..., gt=0)


class MeetingsDelIn(CamelModel):
    id: int = Field(..., gt=0)


class MeetingsOut(CamelModel):
    id: int
    title: str
    description: Union[str, None]
    owner_id: Union[int, None]
    start_time: Union[datetime, None]
    end_time: Union[datetime, None]
    create_time: Union[datetime, None]

    class Config:
        from_attributes = True
